<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        async function getData() {
            console.log('开始代码运行');
            const awaitResult = await new Promise((resolve, reject) => {
                // throw new Error('警告')
                try{setTimeout(()=>{
                    console.log('计时器内的代码');
                    resolve('数据')
                },2000)}
                catch(e){
                    reject(e.message)
                }
            })

            console.log('awaitResult',awaitResult); 
            return Promise.resolve(1)
        }

        const result = getData()
        console.log("result", result);
    </script>
</body>

</html>